package com.zz.comframe.properties;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.Properties;

class test {
	public static Properties getPro() throws FileNotFoundException, IOException {
		Properties pro = new Properties();
		File f = new File("fruit.properties");
		if (f.exists()) {
			pro.load(new FileInputStream(f));
		}
		return pro;
	}

	public static void main(String[] a) throws FileNotFoundException, IOException {
		//File file = new File("/en_db.profile");
		String filepath = (new File(".")).getCanonicalPath()+"\\WebRoot\\WEB-INF\\classes\\com\\zz\\comframe\\properties";
		File file = new File(filepath + "\\en_db.profile");
		byte[] tmpbuf = new byte[1024];
		ByteArrayOutputStream bout = new ByteArrayOutputStream();
		FileInputStream fis = new FileInputStream(file);
		int count = 0;
		while ((count = fis.read(tmpbuf)) != -1) {
			bout.write(tmpbuf, 0, count);
			tmpbuf = new byte[1024];
		}
		System.out.println(DESEncryptUtil.doDecrypt(PropertiesPool.getMik(), bout.toByteArray()));

//		fis = new FileInputStream(file);
//		InputStream raw = DESEncryptUtil.doDecrypt(Constants.getMik(), fis);
//		count = 0;
//		bout = new ByteArrayOutputStream();
//		while ((count = raw.read(tmpbuf)) != -1) {
//			bout.write(tmpbuf, 0, count);
//			tmpbuf = new byte[1024];
//		}
//		raw.close();
//		byte[] orgData = bout.toByteArray();
//		// file = new File("rs_" + file.getName());
//		// FileOutputStream fos = new FileOutputStream(file);
//		// fos.write(orgData);
//		String s = new String(orgData);
//		System.out.println(s);
//		// System.out.println("成功解密，解密文件位于:"+Constants.getCommonpro().getProperty("appale"));
		Iterator keys = PropertiesPool.getCommonpro().keySet().iterator();
		while(keys.hasNext())
			System.out.println(PropertiesPool.getCommonpro((String)keys.next()));
		keys = PropertiesPool.getEncryptpro().keySet().iterator();
		while(keys.hasNext())
			System.out.println(PropertiesPool.getEncryptpro((String)keys.next()));
	

	

	}
}
